package com.example.mall.mapper;

import com.example.mall.pojo.*;
import lombok.Data;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SpRoleMapper {
//
    @Select("select * from sp_role where role_id=#{role_id}")
    SpRole selectById(short rId);

    @Select("select role_id as id ,role_name as roleName,role_desc as roleDesc from sp_role")
    List<Role> selectSpRoleAll();

    @Select("select * from sp_role")
    List<SpRole> selectSpRoleAll1();

    @Select("select * from  sp_permission where ps_pid=#{#ps_pid}")
    List<SpPermission> selectSpRoleAll2(Integer psPid);

    @Select ("select ps_id as id,ps_name as authName, ps_c as path from sp_permission  where ps_level=0 ")
    List<Role1> selectFirst();

    @Select ("select ps_id as id,ps_name as roleName, ps_c as path from sp_permission  where ps_pid=#{#ps_pid} ")
    List<Role2> selectSecond(Integer psPid);

    @Select ("select ps_id as id,ps_name as roleName, ps_c as path from sp_permission  where ps_id=#{#ps_id}  ")
    List<Role3> selectThird(Integer psPid);

    @Select("select * from sp_permission where ps_id=#{ps_id}")
    List<SpPermission> selectSpRole(Integer psId);

    @Select("select * from sp_permission where ps_id=#{ps_id}")
    SpPermission selectSpRole1(Integer psId);

    @Insert("insert  into sp_role(role_name,role_desc) values(#{role_name},#{role_desc})")
    int insertRoles(@Param("role_name") String role_name,@Param("role_desc") String role_desc);

    @Select("select role_id as roleId ,role_name as roleName , role_desc as roleDesc from sp_role where role_id= #{role_id}")
    NewRole1 getRoleById(Integer roleId);

    @Update("update sp_role set role_name=#{role_name} ,role_desc=#{role_desc} where role_id=#{role_id} ")
    int updateRoles(@Param("role_name") String role_name,@Param("role_desc") String role_desc,@Param("role_id") Integer role_id);

    @Delete("delete from sp_role where role_id=#{role_id}")
    int deleteRoles(Integer id);



}
